package model;

import model.viewModels.CenterModel;

/**
 * this class represents a dare
 */
public class Dare {

    /**
     * dare id
     */
    private int id;

    /**
     * challenging user
     */
    private User fromUser;

    /**
     * challenged user
     */
    private User toUser;

    /**
     * time stamp
     */
    private String timestamp;

    /**
     * true: fromUser has white, false fromUser has black
     */
    private boolean fromUserWhite;

    /**
     * message of the fromUser
     */
    private String message;

    /**
     * status of the dare
     */
    private boolean declined;

    /**
     * constructor of the dare class
     * 
     * @param dareData
     *            the data of the new dare
     */
    public Dare( String[] dareData )
    {
	this.id = Integer.valueOf( dareData[0] );

	User logU = CenterModel.loggedInUser;
	if ( dareData[1].equals( logU.getNick() ) )
	{
	    this.fromUser = logU;
	    this.toUser = new User( dareData[2] );
	}
	else
	{
	    this.fromUser = new User( dareData[1] );
	    this.toUser = logU;
	}
	this.timestamp = dareData[3];
	this.fromUserWhite = dareData[4].equals( "1" );
	if ( dareData[5].equalsIgnoreCase( "NULL" ) )
	{
	    this.message = "";
	}
	else
	{
	    this.message = dareData[5];
	}

	this.declined = dareData[6].equals( "1" );
    }

    public final int getId()
    {
	return this.id;
    }

    public final User getFromUser()
    {
	return this.fromUser;
    }

    public final User getToUser()
    {
	return this.toUser;
    }

    public final String getTimestamp()
    {
	return this.timestamp;
    }

    public final boolean isFromUserWhite()
    {
	return this.fromUserWhite;
    }

    public final String getMessage()
    {
	return this.message;
    }

    public final boolean isDeclined()
    {
	return this.declined;
    }

    public final void setDeclined( boolean declined )
    {
	this.declined = declined;
    }
}